package com.fjeld.server;

import com.fjeld.middleware.activemq.TopicListener;
import com.fjeld.middleware.activemq.TopicPublisher;
import static com.fjeld.middleware.activemq.BrokerEnum.*;
import com.fjeld.middleware.jaxb.V1ServerRequest;
import com.fjeld.middleware.jaxb.ObjectFactory;

import java.net.URL;

import org.apache.log4j.PropertyConfigurator;

/**
 * Created by IntelliJ IDEA.
 * User: fjelds
 * Date: Jan 17, 2010
 * Time: 11:15:43 PM
 *
 * Main class starting the server for the trading front ends
 */
public class TestStorageServer
{
    public static void main(String[] args)
    {
        configureLogger();

        try
        {
            TopicListener clientListener = new TopicListener(ServerPublisherTopicString.getValue() + ".V1Node");
            TopicPublisher clientPublisher = new TopicPublisher(ServerListenerTopicString.getValue() + ".V1Node");

            ObjectFactory factory = new ObjectFactory();
            V1ServerRequest request = factory.createV1ServerRequest();
            request.setType("getTreeList");
            request.setValue(null);
            clientPublisher.publish(request);
        } catch (Exception e)
        {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }

        
        try
        {
            Thread.sleep(1000);
        } catch (InterruptedException e)
        {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }

        System.exit(0);
    }

    private static void configureLogger()
    {
        ClassLoader loader = TestStorageServer.class.getClassLoader();

        String log4jPropertiesFilename = "/com/log4j.properties";

        if (loader != null)
        {
            URL propertiesFile = TestStorageServer.class.getResource(log4jPropertiesFilename);
            PropertyConfigurator.configure(propertiesFile);
        }
    }

}
